<?php
declare (strict_types = 1);

namespace app\api\controller\v1;

use app\api\controller\Result;
use think\Request;
use app\api\model\Users;
use app\api\model\Userx;
// 使用think自带异常类抛出异常
use app\ExceptionHandle;

class Add
{
    public function index($id)
    {
      
        $data = Users::where('id', $id)->select();
        return json(['code' => 200,'msg' => '查询成功','data'=> $data]);

    }
    
    /**
     * 保存新建的资源
     *
     * @param  \think\Request  $request
     * @return \think\Response
     */
    public function save(Request $request)
    {
        $data = $request->param();
        $user = new Userx;
        // if ($result) {
            // $data = [                                //模拟数据
            //     ['title'=>'影子山门票+影子山车票','price'=>'1000','order_id'=>'1' ],
            //     ['title'=>'影子山门票+影子山车票','price'=>'1000','order_id'=>'1' ],
            //     ['title'=>'何家寨门票+园区车票+游乐设施门票','price'=>'1200','order_id'=>'1' ]
            // ];
            $user->saveAll($data);
            return json(['code' => 200,'msg' => '添加成功','data'=> $data]);
        // }else{
        //       // 使用think自带异常类抛出异常
        // throw new \think\Exception('添加删除', 411);

        // }
    }

}